#pragma once

#include <iostream>
#include <string>

using namespace std;

enum
{
    div_zero = 1,
    mod_zero = 2,
    unknown = 3
};

const string opsum = "+-*/%";

class Task
{
public:
    Task()
    {}
    Task(int x, int y, char op)
        : _x(x), _y(y), _op(op), _result(0), _exitcode(0)
    {
    }
    void run()
    {
        switch (_op)
        {
        case '+':
            _result = _x + _y;
            break;
        case '-':
            _result = _x - _y;
            break;
        case '*':
            _result = _x * _y;
            break;
        case '/':
            if (_y == 0)
                _exitcode = div_zero;
            else
                _result = _x / _y;
            break;
        case '%':
            if (_y == 0)
                _exitcode = mod_zero;
            else
                _result = _x % _y;
            break;
        default:
            _exitcode = unknown;
            break;
        }
    }
    string GetResult()
    {
        string ret = to_string(_x);
        ret += _op;
        ret += to_string(_y);
        ret += "=";
        ret += to_string(_result);
        ret += ",[exitcode: ";
        ret += to_string(_exitcode);
        ret += "]";

        return ret;
    }

    string GetTask()
    {
        string ret = to_string(_x);
        ret += _op;
        ret += to_string(_y);
        ret += "=?";

        return ret;
    }
    ~Task()
    {
    }

private:
    int _x;
    int _y;
    char _op;
    int _result;
    int _exitcode;
};